package ils.domain.model;

import ils.util.HibernateSession;
import ils.util.HibernateSessionManager;
import ils.util.SpringUtil;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: rejeevd
 * Date: 23/09/12
 * Time: 10:38
 * To change this template use File | Settings | File Templates.
 */
public class BranchRepositoryTest
{
    private HibernateSessionManager hibernateSessionManager = new HibernateSessionManager();
    private ApplicationContext context = SpringUtil.getApplicationContext();
    private BranchRepository branchRepository = (BranchRepository)context.getBean("branchRepository");

    @Test
    public void testGetBranch()
    {
        try(HibernateSession session = hibernateSessionManager.getSession())
        {
            Branch branch = branchRepository.getBranch(1);
            Assert.assertNotNull(branch);
            Assert.assertNotNull(branch.getAddress());
            Assert.assertNotNull(branch.getLibrarian());
        }
    }
}
